package cn.ulyer.core.modules.system.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.ulyer.common.jpa.entity.Dict;
import cn.ulyer.common.jpa.entity.QDict;
import cn.ulyer.common.jpa.service.AbstractService;
import cn.ulyer.core.modules.system.service.DictService;
import com.querydsl.jpa.impl.JPAQuery;
import org.springframework.stereotype.Service;

@Service
public class DictServiceImpl extends AbstractService<Dict,Integer> implements DictService {




    @Override
    protected JPAQuery<Dict> buildPageQuery(Object queryModel) {
        QDict qDict = QDict.dict;
        Dict dict = (Dict) queryModel;
        JPAQuery<Dict> query = jpaQueryFactory.selectFrom(qDict);
        if(dict!=null){
            if(StrUtil.isNotBlank(dict.getProperty())){
                query.where(qDict.property.eq(dict.getProperty()));
            }
            if(StrUtil.isNotBlank(dict.getName())){
                query.where(qDict.name.eq(dict.getName()));
            }
            if(StrUtil.isNotBlank(dict.getModule())){
                query.where(qDict.module.eq(dict.getModule()));
            }
        }
        return query;
    }
}
